<html>
<head>
  <title>Notebook</title>
  <!-- Icons & Stylesheets -->
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
  <link rel="stylesheet" href="style.css" />
</head>
<body>
  <!-- Include the library in the page -->
  <script src="https://unpkg.com/vue/dist/vue.js"></script>
  <!-- 使用最新的marked会出现marked is not a function错误，所以这里采用3.0.8版本 -->
  <script src="https://unpkg.com/marked@3.0.8/lib/marked.js"></script>
  <script src="https://unpkg.com/moment"></script>

  <!-- Notebook app -->
  <div id="notebook">
    <!-- 侧边栏 -->
    <aside class="side-bar">
      <div class="tool-bar">
        <button v-on:click='addNote' v-bind:title="addButtonTitle">
          <i class="material-icons">add</i> Add note
        </button>
      </div>
      <div class="notes">
        <div class="note" v-for="note of sortedNotes" @click='selectNote(note)'
        :class="{selected: note === selectedNote}">
          <i class="icon material-icons" v-if="note.favorite">star</i>
          {{ note.title }}
        </div>
      </div>
    </aside>

    <template v-if="selectedNote">
      <!-- Main pane -->
      <section class="main">
        <div class="toolbar">
          <input v-model="selectedNote.title" placeholder="Note title" />
          <button @click="removeNote" title="Remove note">
            <i class="icon material-icons">remove</i>
          </button>
          <button @click="favoriteNote" title="Favorite note">
            <i class="icon material-icons">star</i>
          </button>
        </div>
        <textarea v-model="selectedNote.content"></textarea>
        <div class="toolbar status-bar">
          <span class="date">
            <span class="label">Created</span>
            <span class="value">{{ selectedNote.created | date }}</span>
          </span>
          <span class="lines">
            <span class="label">Lines</span>
            <span class="value">{{ linesCount }}</span>
          </span>
          <span class="words">
            <span class="label">Words</span>
            <span class="value">{{ wordsCount }}</span>
          </span>
          <span class="characters">
            <span class="label">Characters</span>
            <span class="value">{{ charactersCount }}</span>
          </span>
        </div>
      </section>

      <!-- Preview pane -->
      <aside class="preview" v-html="notePreview"></aside>
    </template>

  </div>

  <!-- Some JavaScript -->
  <script src="script.js"></script>
</body>
</html>
